<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
  <style>
    .container {
      position: absolute;
      width: 200px;
      height: 100px;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }

    /* 动画 */
    @keyframes shake {
      0% {
        opacity: 0;
        font-size: 14px;
      }

      50% {
        opacity: 0.3;
        font-size: 60px;
      }

      100% {
        opacity: 1;
        font-size: 40px;
      }
    }

    /* 过渡 */
    .v-enter-from {
      color: red;
    }

    .v-enter-active {
      animation: shake 10s;
      transition: color 3s ease-in;
    }

    .v-leave-active {
      color: red;
      animation: shake 10s; 
      transition: color 3s ease-in;
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script>
    /* 
      1. 过渡和动画都有的场景示例
      - 假设过渡时间为3s，动画时间为10s，通过transition的type的属性
      设置统一以指定值为时长
        - type="transition" 以过渡时长为准
        - type="anmation" 以动画时长为准
      2. duration属性设置动画时长
      - 覆盖过渡、动画给定的时长
      - 方式一 统一设置入场、出场时长
      - 方式二 {enter: 入场时长, leave:出场时长}
    */
    const app = Vue.createApp({
      template: `
      <div class="container">
        <transition type="animation">
          <div v-if="isShow">Hello World1</div>
        </transition>
        <button @click="isShow = !isShow">切换</button>
      </div>
    `,
      data() {
        return {
          isShow: false
        }
      }
    })
    const vm = app.mount('#root');

  </script>
</body>

</html>